package com.gegao.practise;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;




public class TestGestureHelpAnimation extends Activity {
    int[] extractResIdArray = {R.drawable.jianbao_1,R.drawable.jianbao_2,R.drawable.jianbao_3,R.drawable.jianbao_13};
    int[] resourcesDurationArray = {200,200,200,200};
    Button mBt;
    FrameLayout mParent;
    TextView mTitle;
    TutorialGifHelperView mImage;
    View mTipView;
    
    
    RelativeLayout.LayoutParams mParams = new RelativeLayout.LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);
    
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.one_button);
        mBt = (Button)findViewById(R.id.bt);
        
        mParent = (FrameLayout) getWindow()
                .getDecorView().findViewById(android.R.id.content);
        
        mTipView = LayoutInflater.from(this).inflate(R.layout.gesture_animation, null);
        mImage = (TutorialGifHelperView)(ImageView) mTipView.findViewById(R.id.animation);
        
        
        mTipView.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                mParent.removeView(mTipView);
                mImage.stop();

            }
        });
        
        mBt.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v) {
                mParent.addView(mTipView, mParams);
                mImage.init(extractResIdArray, resourcesDurationArray);
            }
        });
        mTitle = (TextView) mTipView.findViewById(R.id.animation_title);
    }
}
